<template>
  <div class="index d-flex">
    <LeftBarVue />
    <MainConVue />
  </div>
</template>

<script>
import LeftBarVue from '@/components/LeftBar/LeftBar.vue'
import MainConVue from './components/MainCon/MainCon.vue'
// store
// 对象里有新的绑定在给定命名空间值上的组件绑定辅助函数
import { createNamespacedHelpers } from 'vuex'
const { mapMutations } = createNamespacedHelpers('index')

export default {
  name: 'Index',

  components: { LeftBarVue, MainConVue },

  methods: {
    ...mapMutations(['SET_chatTitle', 'SET_chatList'])
  },

   watch: {
    '$route.query.chatId'(v) {
      // console.log('chatId', v)
      /* id 为空表示新对话，新对话重置顶部标题 */
      if (!v) {
        this.SET_chatTitle()
      }
    }
  },

  mounted() {
    // console.log('index mounted', this.$route)
    const chatId = this.$route.query.chatId
     /* id 为空表示新对话，新对话重置顶部标题 */
    if (!chatId) {
      this.SET_chatTitle()
    }
  }
}
</script>

<style>
.index {
  height: 100vh;
}
</style>
